package sizeyunsuan;

/**
 * Created by 春旺 on 2017/5/12.
 */

import com.sun.xml.internal.fastinfoset.util.StringArray;
import org.junit.Test;

import java.io.IOException;
import java.lang.reflect.Array;
import java.util.*;

import static java.util.Arrays.copyOfRange;

public class Turn extends IntRandom{
    public String []Turn()throws IOException
    {
        IntRandom b = new IntRandom();
        String[] arr = b.InRandom();
        Stack<String>stack = new Stack<String>();
        for (int i =0;i<arr.length;i++){
           String sr = arr[i];
           for (int j = 0;j < sr.length();j ++){
               if (isOperator(sr.charAt(j)+"")) {

               }
           }


           }

        return
    }
    private boolean isOperator (String token)
    {
        return ( token.equals("+") || token.equals("-") ||
                token.equals("*") || token.equals("/") );
    }
    public int evaluate (String expr)
    {
        int op1, op2, result = 0;
        String token;
        StringTokenizer tokenizer = new StringTokenizer (expr);

        while (tokenizer.hasMoreTokens()) {
            token = tokenizer.nextToken();

            //如果是运算符，调用isOperator
            if (isOperator(token)   )
            {
                op2 = stack.pop().intValue();
                op1 = stack.pop().intValue();
                result = evalSingleOp(token.charAt(0),op1,op2);
                stack.push(result);
                //从栈中弹出操作数2
                //从栈中弹出操作数1
                //根据运算符和两个操作数调用evalSingleOp计算result;
                //计算result入栈;
            }
            else {
                stack.push(Integer.parseInt(token));
                //如果是操作数
                //操作数入栈;
            }
}